package modellayer;

import java.util.ArrayList;


/**
 * The class Order is to hold information about a given order and which products this order contains.
 * A object of the order is to be saved in the OrderContainer class.
 * 
 * @author Allan Eriksen, Christian Stidsborg, Andreas Rye, Casper Madsen, Stefan Bols 
 * @version 051213
 */

public class PartOrder 
{
	private ArrayList<ProductCopy> productCopyList;
	private double price;	
	private double VAT;
	private double priceWithoutVAT;
	
	public PartOrder()
	{
		this.productCopyList = new ArrayList<ProductCopy>();
		this.price = 0.0;
		this.VAT = 0.0;
		this.priceWithoutVAT = 0.0;
	}
	
	public void addProductCopy(ProductCopy productCopy)
	{
		productCopyList.add(productCopy);
	}
	
	// enkelt pris m/moms
	public double getPrice()
	{
		int size = productCopyList.size();
		double newPrice;
		double currentPrice = 0;
		
		for( ProductCopy productCopy : productCopyList)
		{			
			newPrice = productCopy.getPrice();
			currentPrice = newPrice + currentPrice;
			price = currentPrice / size;
		}
		
		return price;
	}
	
	public double getPricePrWithoutTax() {
		return getPrice()*0.2;
	}
	
	// pris for det hele med moms
	public double getTotalPrice()
	{
		double newPrice;
		double currentPrice = 0;
		
		for( ProductCopy productCopy : productCopyList)
		{			
			newPrice = productCopy.getPrice();
			currentPrice = newPrice + currentPrice;
			price = currentPrice;
		}
		
		return price;
	}
	
	public int getNoOfCopies()
	{
		int size = productCopyList.size();
		
		return size;
	}
	
	// moms af det totale
	public double calculateVAT()
	{
		VAT = getTotalPrice() / 100 * 20;
		
		return VAT;
	}
	
	// pris ialt uden moms
	public double priceTotalWithoutVAT()
	{
		priceWithoutVAT = getTotalPrice() - calculateVAT();
		
		return priceWithoutVAT;
	}
	
	public String getProductBarcode() {
		return productCopyList.get(0).getProductObj().getBarcode();
	}
	
	public String getProductNo() {
		return productCopyList.get(0).getProductObj().getProductNo();
	}
	
	public String getProductLabel() {
		return productCopyList.get(0).getProductObj().getProductLabel();
	}
	
	public ArrayList<ProductCopy> getCopyList() {
		return productCopyList;
	}
	
}
